Skip to content

Error with cursor position in PSReadLine #4742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
Aleeza5808 opened this issue May 15, 2025 · 1 comment
Closed
3 tasks done

Error with cursor position in PSReadLine #4742

Aleeza5808 opened this issue May 15, 2025 · 1 comment

Comments

@Aleeza5808
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

PS C:\Users\Dell\Desktop\Project>

Oops, something went wrong.  Please report this bug with the details below.
Report on GitHub: https://github.com/lzybkr/PSReadLine/issues/new
-----------------------------------------------------------------------
Last 3 Keys:
 & Space C

Exception:
Parameter name: left
Actual value was -2.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)
   at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)     
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)
-----------------------------------------------------------------------
PS C:\Users\Dell\Desktop\Project> & C:/Users/Dell/AppData/Local/Programs/Python/Python312/python.exe c:/Users/Dell/Desktop/Project/sign-language-detector-python-master/create_dataset.py
2025-05-15 17:21:55.102876: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.     
2025-05-15 17:21:58.384349: I tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.     
Data and labels saved to 'data.pickle'
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
W0000 00:00:1747311726.726756    2488 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
W0000 00:00:1747311726.833878   14924 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.

Screenshot

Image

Environment data

Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      19041  5737
ConsoleHost
Version
-------
2.0.0

Major  Minor  Build  Revision
-----  -----  -----  --------
10     0      19045  0
149
15

Steps to reproduce

import os
import pickle
import mediapipe as mp
import cv2

mp_hands = mp.solutions.hands
mp_drawing = mp.solutions.drawing_utils

hands = mp_hands.Hands(static_image_mode=True, min_detection_confidence=0.3)

Correct the DATA_DIR to only include the directory path

DATA_DIR = r'C:\Users\Dell\Desktop\Project\data\leapGestRecog\00'

data = []
labels = []

List all files in the directory

for img_path in os.listdir(DATA_DIR):
if img_path.lower().endswith(('.png', '.jpg', '.jpeg')): # Check for image file extensions
img_path_full = os.path.join(DATA_DIR, img_path)
img = cv2.imread(img_path_full)
if img is None:
print(f"Failed to load image: {img_path_full}")
continue

    img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    results = hands.process(img_rgb)

    data_aux = []
    x_ = []
    y_ = []

    if results.multi_hand_landmarks:
        for hand_landmarks in results.multi_hand_landmarks:
            for i in range(len(hand_landmarks.landmark)):
                x = hand_landmarks.landmark[i].x
                y = hand_landmarks.landmark[i].y

                x_.append(x)
                y_.append(y)

            for i in range(len(hand_landmarks.landmark)):
                x = hand_landmarks.landmark[i].x
                y = hand_landmarks.landmark[i].y
                data_aux.append(x - min(x_))
                data_aux.append(y - min(y_))

    data.append(data_aux)
    labels.append(img_path)  # Use the image filename as the label

Save the data and labels to a pickle file

with open('data.pickle', 'wb') as f:
pickle.dump({'data': data, 'labels': labels}, f)

print(f"Data and labels saved to 'data.pickle'")

Expected behavior

Expected Behavior:
PSReadLine should correctly manage cursor positions without throwing errors.
The Python script should run without generating TensorFlow Lite warnings, or the warnings should not affect the script's functionality.

Actual behavior

Actual Behavior:
When using PSReadLine in PowerShell, an error occurs where the cursor position is incorrectly set to -2, leading to the following error message:
Copy
Exception:
Parameter name: left
Actual value was -2.
at System.Console.SetCursorPosition(Int32 left, Int32 top)
at Microsoft.PowerShell.Internal.VirtualTerminal.set_CursorLeft(Int32 value)
...
This error prevents normal operation of the console, potentially causing the console to malfunction or display incorrectly.
Additionally, when running a Python script that processes images and uses MediaPipe for hand gesture detection, warnings related to TensorFlow Lite are displayed:
Copy
INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
WARNING: All log messages before absl::InitializeLog() is called are written to STDERR
W0000 00:00:1747311726.726756 2488 inference_feedback_manager.cc:114] Feedback manager requires a model with a single signature inference. Disabling support for feedback tensors.
These warnings do not seem to affect the script's ability to save data to 'data.pickle', but they indicate potential issues with the TensorFlow Lite configuration.
Steps to Reproduce:
Open PowerShell.
Use PSReadLine to navigate and edit command lines.
Observe the error when the cursor position is set to an invalid value.
Run the Python script create_dataset.py that processes images.
Note the TensorFlow Lite warnings during script execution.

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 15, 2025
Copy link

@Aleeza5808, you were using a pretty old version of PSReadLine (2.0.0-beta2 or prior), and it's likely that the issue was fixed in a newer version.
Please upgrade to the 2.3.5 version of PSReadLine from PowerShell Gallery.
See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label May 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant