!91 修复 BUG 出现滚动条后,退格可能会导致行号错位

Merge pull request !91 from 格物方能致知/fix-I7UK2L
This commit is contained in:
格物方能致知 2023-09-12 14:35:19 +00:00 committed by Gitee
commit 28db9f2950
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 19 additions and 9 deletions

View File

@ -6,9 +6,9 @@
<groupId>org.jcnc</groupId> <groupId>org.jcnc</groupId>
<artifactId>JNotepad</artifactId> <artifactId>JNotepad</artifactId>
<version>1.11.2-SNAPSHOT</version> <version>1.1.3-bate</version>
<name>JNotepad</name> <name>JNotepad</name>
<packaging>jar</packaging>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@ -25,7 +25,13 @@ import java.util.Map;
public class PluginManager { public class PluginManager {
private static final PluginManager INSTANCE = new PluginManager(); private static final PluginManager INSTANCE = new PluginManager();
Logger logger = LogUtil.getLogger(this.getClass()); Logger logger = LogUtil.getLogger(this.getClass());
/**
* 插件集合
*/
private final List<Plugin> plugins = new ArrayList<>(); private final List<Plugin> plugins = new ArrayList<>();
/**
* 插件类别
*/
private final Map<String, List<String>> categories = new HashMap<>(); private final Map<String, List<String>> categories = new HashMap<>();
private PluginManager() { private PluginManager() {

View File

@ -79,7 +79,6 @@ public class LineNumberTextArea extends BorderPane {
// 初始化监听器用于处理事件 // 初始化监听器用于处理事件
initListeners(); initListeners();
// 将主文本区域设置为中央内容将行号区域设置为左侧内容 // 将主文本区域设置为中央内容将行号区域设置为左侧内容
setCenter(mainTextArea); setCenter(mainTextArea);
setLeft(lineNumberArea); setLeft(lineNumberArea);
@ -202,10 +201,13 @@ public class LineNumberTextArea extends BorderPane {
// 循环迭代生成行号文本, // 循环迭代生成行号文本,
for (int i = 1; i <= numOfLines; i++) { for (int i = 1; i <= numOfLines; i++) {
// 将行号和换行符添加到字符串中 // 将行号和换行符添加到字符串中
lineNumberText.append(i).append("\n"); lineNumberText.append(i);
if (i != numOfLines) {
lineNumberText.append("\n");
}
} }
// 将生成的行号文本设置到行号区域 // 将生成的行号文本设置到 行号区域
lineNumberArea.setText(lineNumberText.toString()); lineNumberArea.setText(lineNumberText.toString());
// 恢复主文本区域的垂直滚动位置 // 恢复主文本区域的垂直滚动位置

View File

@ -4,19 +4,21 @@
-fx-vbar-policy: as-needed; -fx-vbar-policy: as-needed;
} }
/* 不显示滚动条 */ /*!* 不显示滚动条 *!*/
/*.text-line-number .content {*/
/* -fx-cursor: text;*/
/* -fx-padding: 8px 1px 8px 5px;*/
/*}*/
.text-line-number .content { .text-line-number .content {
-fx-cursor: text;
-fx-padding: 8px 1px 8px 5px; -fx-padding: 8px 1px 8px 5px;
} }
.text-line-number .scroll-bar:vertical { .text-line-number .scroll-bar:vertical {
-fx-pref-width: 1; -fx-pref-width: 1;
-fx-opacity: 0; -fx-opacity: 0;
} }
.text-line-number .scroll-bar:horizontal { .text-line-number .scroll-bar:horizontal {
-fx-pref-height: 1; -fx-pref-height: 10;
-fx-opacity: 0; -fx-opacity: 0;
} }